package com.ruoyi.camp.api;

import com.ruoyi.camp.domain.CCamp;
import com.ruoyi.camp.service.ICCampService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static com.ruoyi.common.core.domain.AjaxResult.success;

@RestController
@RequestMapping("/wechat/camp")
public class WxCampController extends BaseController {

    @Autowired
    private ICCampService cCampService;

    /**
     * 查询camp
     * @param cCamp
     * @return
     */
    @GetMapping("/listCamp")
    public AjaxResult list(CCamp cCamp)
    {
        startPage();
        List<CCamp> list = cCampService.selectCCampList(cCamp);
        return success(list);
    }

    /**
     * 新增camp
     */
    @PostMapping("/addCamp")
    public AjaxResult add(@RequestBody CCamp cCamp)
    {
        return success(cCampService.insertCCamp(cCamp));
    }

    @GetMapping(value = "/{campId}")
    public AjaxResult getInfo(@PathVariable("campId") String campId)
    {
        return success(cCampService.selectCCampByCampId(campId));
    }
}
